package com.example.administrator.energyida.activity;

import android.app.Activity;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.bin.david.form.annotation.SmartColumn;
import com.bin.david.form.annotation.SmartTable;
import com.example.administrator.energyida.R;
import com.jaeger.library.StatusBarUtil;

import java.util.ArrayList;
import java.util.List;

public class TableActivity extends Activity {

    private TextView back;
    private com.bin.david.form.core.SmartTable smartTable;
    private List<UserInfo> list;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_table);

        // 设置状态栏的颜色
        StatusBarUtil.setColor(TableActivity.this, Color.parseColor("#10cafd"), 50);

        initView();
        setData();

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void setData() {
        list = new ArrayList<>();
        UserInfo userInfo1 = new UserInfo();
        userInfo1.wName = "车间1";
        userInfo1.wData = 200;
        list.add(userInfo1);
        smartTable.setData(list);
    }

    @SmartTable(name="报表")
    class UserInfo {
        @SmartColumn(id =1,name = "车间")
        private String wName;
        @SmartColumn(id=2,name="数据")
        private int wData;
    }

    private void initView() {
        smartTable = findViewById(R.id.smartTable);
        back = findViewById(R.id.text_table_back);
    }
}
